use strict;
use warnings;

$forum::q_get_current_user = 'SELECT*FROM FM_USERS WHERE SESS_ID=? LIMIT 1';
$forum::q_find_user='SELECT*FROM FM_USERS WHERE USERNM=? AND PASSWD=HEX(?)LIMIT 1';
$forum::d_create_user='INSERT INTO FM_USERS(USERNM,PASSWD,EMAIL,HIDEE,IP_ADDR,HOSTNAME)VALUES(?,HEX(?),?,?,?,?)';
$forum::d_set_sess_id = 'UPDATE FM_USERS SET SESS_ID=? WHERE ID=?';

$forum::q_get_users = 'SELECT*FROM FM_USERS ORDER BY ID DESC LIMIT ?,?';

$forum::q_get_board = 'SELECT*FROM FM_BOARDS WHERE ID=?';
$forum::q_get_boards = 'SELECT B.*,LT.ID LT_ID,LT.TITLE LT_TITLE,LT.DT_STARTED LT_DT_STARTED,LTU.ID LTU_ID,LTU.USERNM LTU_USERNM,LP.ID LP_ID,LP.DT_POSTED LP_DT_POSTED,LPT.ID LPT_ID,LPT.TITLE LPT_TITLE,LPU.ID LPU_ID,LPU.USERNM LPU_USERNM FROM FM_BOARDS B LEFT JOIN(FM_TOPICS LT,FM_USERS LTU,FM_POSTS LP,FM_TOPICS LPT,FM_USERS LPU)ON B.LAST_TOPIC=LT.ID AND LT.STARTER=LTU.ID AND B.LAST_POST=LP.ID AND LP.TOPIC=LPT.ID AND LP.POSTER=LPU.ID';
$forum::q_get_topic = 'SELECT T.*,B.TITLE B_TITLE FROM FM_TOPICS T,FM_BOARDS B WHERE T.ID=? AND T.BOARD=B.ID';
$forum::q_get_topics = 'SELECT T.*,LP.DT_POSTED AS LP_DT_POSTED,U.USERNM AS U_USERNM FROM FM_TOPICS T,FM_POSTS LP,FM_USERS U WHERE BOARD=? AND T.LAST_POST=LP.ID AND T.STARTER=U.ID ORDER BY LP_DT_POSTED DESC LIMIT ?,?';
$forum::q_get_post = 'SELECT P.*,T.TITLE T_TITLE,B.TITLE B_TITLE,U.USERNM U_USERNM FROM FM_POSTS P,FM_TOPICS T,FM_BOARDS B,FM_USERS U WHERE P.ID=? AND P.TOPIC=T.ID AND T.BOARD=B.ID AND P.POSTER=U.ID';
$forum::q_get_posts = 'SELECT P.*,U.USERNM U_USERNM FROM FM_POSTS P,FM_USERS U WHERE P.TOPIC=? AND P.POSTER=U.ID ORDER BY DT_POSTED LIMIT ?,?';

$forum::d_make_topic = 'CALL FM_MAKE_TOPIC(?,?,?,?,?,@TOPIC_ID, @POST_ID)';
$forum::d_make_post = 'CALL FM_MAKE_POST(?,?,?,?,?,@POST_ID)';
$forum::d_edit_post = 'UPDATE FM_POSTS SET CONTENT=? WHERE ID=?';
$forum::d_edit_topic = 'UPDATE FM_TOPICS SET TITLE=?,DESCR=? WHERE ID=?';
